import re
from collections import Counter

with open('input.txt', 'r', encoding='utf-8') as f:
    text = f.read()

words = re.findall(r'\b\w+\b', text)

counter = Counter(words)

with open('output.txt', 'w', encoding='utf-8') as f:
    for word, freq in counter.items():
        f.write(f'{word} {freq}\n')

print("统计完成，结果已写入 output.txt")